package view;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;

import java.awt.Color;

import javax.swing.JRadioButton;
import javax.swing.SwingConstants;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.border.CompoundBorder;

@SuppressWarnings("serial")
public class LoginPanel extends JPanel {
	private JTextField textField;
	private JPasswordField passwordField;

	/**
	 * Create the panel.
	 */
	public LoginPanel() {
		setBorder(new LineBorder(new Color(0, 0, 0), 4));
		
		textField = new JTextField();
		textField.setColumns(10);
		
		passwordField = new JPasswordField();
		
		JLabel lblUsername = new JLabel("Username");
		
		JLabel lblPassword = new JLabel("Password");
		
		JPanel panelLogType = new JPanel();
		panelLogType.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0)), "Login As:", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		JButton btnLogin = new JButton("Login");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(78)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(15)
							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
								.addComponent(lblUsername)
								.addComponent(lblPassword))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(passwordField, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
								.addComponent(textField, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE))
							.addGap(14))
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(panelLogType, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)))
					.addGap(80))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(56)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblUsername))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblPassword))
					.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addComponent(panelLogType, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE))
					.addGap(90))
		);
		
		ButtonGroup rdbtnGrpLogType = new ButtonGroup();
		
		JRadioButton rdbtnAdmin = new JRadioButton("Administrator");
		rdbtnAdmin.setVerticalAlignment(SwingConstants.TOP);
		
		JRadioButton rdbtnAnalyst = new JRadioButton("Analyst");
		GroupLayout gl_panelLogType = new GroupLayout(panelLogType);
		gl_panelLogType.setHorizontalGroup(
			gl_panelLogType.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panelLogType.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panelLogType.createParallelGroup(Alignment.LEADING)
						.addComponent(rdbtnAdmin)
						.addComponent(rdbtnAnalyst))
					.addContainerGap(9, Short.MAX_VALUE))
		);
		gl_panelLogType.setVerticalGroup(
			gl_panelLogType.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panelLogType.createSequentialGroup()
					.addComponent(rdbtnAdmin)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(rdbtnAnalyst)
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panelLogType.setLayout(gl_panelLogType);
		
		rdbtnGrpLogType.add(rdbtnAnalyst);
		rdbtnGrpLogType.add(rdbtnAdmin);
		setLayout(groupLayout);

	}
}
